<template>
  <div class="page accountDel">
    <div class="scroll-view">
      <customHeader middleTitle="账号注销" />
      <div class="page-body">
        <div class="section">
          <div class="icon" @click="deleteAccount"></div>
          <div class="title">账号注销</div>
          <div
            class="text"
          >很遗憾，同福商家无法继续为您提供服务，感谢您一直以来的陪伴。注销成功后，您账号中的所有订单、对账单、短信、营销活动等所有数据都将被清空。</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
import customHeader from "../../components/header/header";
import { Toast, MessageBox } from "mint-ui";

export default {
  name: "accountDel",
  data() {
    return {

    };
  },
  methods: {
    deleteAccount() {
      MessageBox.confirm("您确定要注销账户吗?注册后，将退出并无法再次登录", '').then(action => {
        this.requestDeleteAccount();
      }).catch(() => {
        
      });
    },
    requestDeleteAccount() {
			this.ajax({
				url: '/app/setting/closeAccountForIOS.do',
				type: 'get',
				controlLoading: true,
				data: {},
			})
      .then(res => {
        if (res != null && res.success) {
          console.log('/app/setting/closeAccountForIOS.do：', res);
          MessageBox.alert("账户已注销").then(action => {
            this.logout();
          });
        } else {
          Toast('当前网络异常，请稍后再试~');
        }
      })
      .catch(err => {
        console.log('err', err);
      });
    },
    logout() {
      localStorage.clear();
      AppUtil.call(AppUtil.APIS.LOGOUT);
    }
  },
  components: {
    customHeader
  }
};
</script>
<style lang='scss' scoped>
@import "accountDel";
</style>
